package com.nwpu.coursesupport.tool;

import com.nwpu.coursesupport.enumeration.FileType;

public class FileUtil {
	
	public static String getExtensionName(String fileName){
		int index=fileName.lastIndexOf('.');
		String extensionName=fileName.substring(index+1);
		return extensionName;
	} 
	public static String getFileName(String fileName){
		int index=fileName.lastIndexOf('.');
		String name=fileName.substring(0,index);
		return name;
	}
	
	public static FileType getFileType(String fileName){
		String extendName=getExtensionName(fileName);
		for (FileType f: FileType.values()){
			if(f!=FileType.DEFAULT&&f.getName().contains(extendName)){
				return f;
			}
		}
		return FileType.DEFAULT;
	}

}
